<%--
  Created by IntelliJ IDEA.
  User: laoyu
  Date: 2019/9/4
  Time: 8:59
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <title>文件上传</title>
</head>
<body>
<h3>单文件上传</h3>
<form id="attachForm" method="post" action="/file/one/upload.html" enctype="multipart/form-data">
    <div>
        <input type="file" name="attach" id="attach" onchange="changepic(this)" accept="image/*">
        <input type="submit" value="上传">
    </div>
    <div>
        <img src="" id="show" width="60%" height="60%">
    </div>
</form>

<h3>多文件上传</h3>
<form method="post" action="/file/more/upload.html" enctype="multipart/form-data">
    <div>
        <input type="file" name="myFiles" multiple="multiple">
        <input type="submit" value="上传">
    </div>
</form>
<h3>文件下载</h3>
<a href="/file/download?fileName=macbook.png">下载</a>
<a href="/file/download?fileName=过渡.gif">下载</a>
<script>
    function changepic() {
        var reads= new FileReader();
        var f=document.getElementById('attach').files[0];
        reads.readAsDataURL(f);
        reads.onload=function (e) {
            document.getElementById('show').src=this.result;
        };
    }
</script>
</body>
</html>
